/**
* 左边菜单
*/
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path"
    unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff"
    active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/' + chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '用户管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'icon-cat-skuQuery',
              menuname: '用户列表',
              hasThird: 'N',
              url: 'user/User',
              menus: null
            }
          ]
        },
        {
          menuid: 120,
          icon: 'li-icon-xiangmuguanli',
          menuname: '教师管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 122,
              icon: 'icon-cat-skuQuery',
              menuname: '教师分类',
              hasThird: 'N',
              url: 'teacher/teacherClassify',
              menus: null
            },
            {
              menuid: 1142,
              icon: 'icon-cat-skuQuery',
              menuname: '教师列表',
              hasThird: 'N',
              url: 'teacher/teacherList',
              menus: null
            },
          ]
        },
        {
          menuid: 1920,
          icon: 'li-icon-xiangmuguanli',
          menuname: '课程管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 1912,
              icon: 'icon-cat-skuQuery',
              menuname: '课程首页分类列表',
              hasThird: 'N',
              url: 'course/courseIndexList',
              menus: null
            },
            {
              menuid: 1913,
              icon: 'icon-cat-skuQuery',
              menuname: '课程二级分类列表',
              hasThird: 'N',
              url: 'course/courseIndexTwoList',
              menus: null
            },
            {
              menuid: 1914,
              icon: 'icon-cat-skuQuery',
              menuname: '课程列表',
              hasThird: 'N',
              url: 'course/courseList',
              menus: null
            }
          ]
        },
        {
          menuid: 110,
          icon: 'li-icon-xiangmuguanli',
          menuname: '栏目页管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 112,
              icon: 'icon-cat-skuQuery',
              menuname: '栏目页列表',
              hasThird: 'N',
              url: 'columnPage/columnPageClassify',
              menus: null
            }
          ]
        },
        {
          menuid: 1109,
          icon: 'li-icon-xiangmuguanli',
          menuname: '国际学校管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 112,
              icon: 'icon-cat-skuQuery',
              menuname: '学校年级分类',
              hasThird: 'N',
              url: 'school/gradeClassification',
              menus: null
            },
            {
              menuid: 113,
              icon: 'icon-cat-skuQuery',
              menuname: '学校类型',
              hasThird: 'N',
              url: 'school/schoolType',
              menus: null
            },
            {
              menuid: 114,
              icon: 'icon-cat-skuQuery',
              menuname: '校区网点',
              hasThird: 'N',
              url: 'school/shcoolSite',
              menus: null
            },
            {
              menuid: 115,
              icon: 'icon-cat-skuQuery',
              menuname: '学校列表',
              hasThird: 'N',
              url: 'school/schoolList',
              menus: null
            },
          ]
        },
        {
          menuid: 333,
          icon: 'li-icon-xiangmuguanli',
          menuname: '资讯管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 3331,
              icon: 'icon-cat-skuQuery',
              menuname: '资讯类别列表',
              hasThird: 'N',
              url: 'information/InformationCategory',
              menus: null
            },
            {
              menuid: 3332,
              icon: 'icon-cat-skuQuery',
              menuname: '资讯列表',
              hasThird: 'N',
              url: 'information/InformationTable',
              menus: null
            }
          ]
        },
        {
          menuid: 10,
          icon: 'li-icon-xiangmuguanli',
          menuname: '平台管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 12178,
              icon: 'icon-cat-skuQuery',
              menuname: '基本信息配置',
              hasThird: 'N',
              url: 'terrace/terraceBasic',
              menus: null
            },
            {
              menuid: 121710,
              icon: 'icon-cat-skuQuery',
              menuname: '卡尔顿信息配置',
              hasThird: 'N',
              url: 'terrace/terraceCarleton',
              menus: null
            },
            {
              menuid: 12,
              icon: 'icon-cat-skuQuery',
              menuname: '轮播图管理',
              hasThird: 'N',
              url: 'terrace/Carousel',
              menus: null
            },
            {
              menuid: 121,
              icon: 'icon-cat-skuQuery',
              menuname: '首页顶部跳转管理',
              hasThird: 'N',
              url: 'terrace/IndexJump',
              menus: null
            },
            {
              menuid: 122,
              icon: 'icon-cat-skuQuery',
              menuname: '选课中心跳转管理',
              hasThird: 'N',
              url: 'terrace/ActivityJump',
              menus: null
            },
            {
              menuid: 123,
              icon: 'icon-cat-skuQuery',
              menuname: '择校服务跳转管理',
              hasThird: 'N',
              url: 'terrace/SchoolJump',
              menus: null
            },
            {
              menuid: 124,
              icon: 'icon-cat-skuQuery',
              menuname: '课程体系跳转管理',
              hasThird: 'N',
              url: 'terrace/CourseJump',
              menus: null
            },
            {
              menuid: 12498,
              icon: 'icon-cat-skuQuery',
              menuname: '友情链接',
              hasThird: 'N',
              url: 'terrace/blogroll',
              menus: null
            },
            {
              menuid: 12412,
              icon: 'icon-cat-skuQuery',
              menuname: '考试百科',
              hasThird: 'N',
              url: 'terrace/encyclopedia',
              menus: null
            },
          ]
        },
      ],
      msg: 'success'
    }


    var Admin = [{
      menuid: 999,
      icon: 'li-icon-xiangmuguanli',
      menuname: '系统管理',
      hasThird: null,
      url: null,
      menus: [
        {
          menuid: 71,
          icon: 'icon-cat-skuQuery',
          menuname: '管理员设置',
          hasThird: 'N',
          url: 'system/Admin',
          menus: null
        }
      ]
    }]

    var userdata = JSON.parse(localStorage.getItem("userdata"))

    if (userdata.rolesId == "1") {
      res.data = Admin
    }
    this.allmenu = res.data
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}

.el-menu-item-group__title {
  padding: 0px;
}

.el-menu-bg {
  background-color: #1f2d3d !important;
}

.el-menu {
  border: none;
}

.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}

.logoimg {
  height: 40px;
}
</style>